package com.jz.community.moduleshoppingguide.home.presenter;

import com.jz.community.basecomm.mvp.BaseLifeCyclePresent;
import com.jz.community.basecomm.net.rxandroid.OnLoadListener;
import com.jz.community.moduleshoppingguide.home.bean.CategoriesGoodsBean;
import com.jz.community.moduleshoppingguide.home.model.ShoppingGuideModel;
import com.jz.community.moduleshoppingguide.home.model.ShoppingModelGuideImpl;
import com.jz.community.moduleshoppingguide.home.ui.ShoppingGuidePageView;

/**
 * Created by Tony.Fan on 2018/3/13 10:42
 */
public class ShoppingGuidePagePresenter extends BaseLifeCyclePresent<ShoppingGuidePageView.View> implements ShoppingGuidePageView.Presenter {

    private ShoppingGuideModel shoppingModel;
    private ShoppingGuidePageView.View mView;

    public ShoppingGuidePagePresenter(ShoppingGuidePageView.View v) {
        mView = v;
        shoppingModel = new ShoppingModelGuideImpl(v.getContext());
    }

    @Override
    public void setPresenter(ShoppingGuidePageView.View v) {
        super.setPresenter(v);
    }

    @Override
    public void getCategorysGoodsInfoes(String goodsCategoryId, int page, int size, int type) {
        shoppingModel.chunnelShowCategories(goodsCategoryId, page, size, new OnLoadListener<CategoriesGoodsBean>() {
            @Override
            public void onSuccess(CategoriesGoodsBean categoriesGoodsBean) {
                mView.showCategorysGoodsInfoes(categoriesGoodsBean, type);
            }

            @Override
            public void onFail(String msg, int code) {
                mView.onFail(msg,code);
            }
        });
    }
}
